package com.hup.joystick.view.joySetting;

import com.hup.joystick.model.DeviceConfig;
import com.hup.utils.swing.customView.HComboBox;
import com.hup.utils.swing.customView.HScrollPanel;
import com.hup.utils.swing.customView.ImageButton;
import com.hup.utils.swing.customView.ViewText;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

/**
 * @author hugan
 * @date 2020/10/19
 */
public class JoySettingForm {
    public JPanel root;
    public HComboBox<DeviceConfig> cbDevice;
    public JRadioButton cbXInput;
    public JRadioButton cbDInput;
    public JRadioButton cbHid;
    public ImageButton btnRefresh;
    public ImageButton btnDelete;
    public ImageButton btnAddKey;
    public ViewText txtAppConfigInfo;

    public HScrollPanel spKey;
    public JTextArea txtInfo;
    public JPanel pKey;
    public JTextArea txtStateInfo;

    public JButton btnSave;
    public JButton btnCancel;

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        root = new JPanel();
        root.setLayout(new GridBagLayout());
        root.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel1, gbc);
        final JLabel label1 = new JLabel();
        label1.setText("设备");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 0, 0, 5);
        panel1.add(label1, gbc);
        final JLabel label2 = new JLabel();
        label2.setText("连接方式");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 0, 0, 5);
        panel1.add(label2, gbc);
        cbDevice = new HComboBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel1.add(cbDevice, gbc);
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.gridwidth = 3;
        gbc.fill = GridBagConstraints.BOTH;
        panel1.add(panel2, gbc);
        cbXInput = new JRadioButton();
        cbXInput.setSelected(true);
        cbXInput.setText("XInput");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        panel2.add(cbXInput, gbc);
        cbDInput = new JRadioButton();
        cbDInput.setText("DInput");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        panel2.add(cbDInput, gbc);
        cbHid = new JRadioButton();
        cbHid.setText("HID");
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        panel2.add(cbHid, gbc);
        final JPanel spacer1 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel2.add(spacer1, gbc);
        btnAddKey = new ImageButton();
        btnAddKey.setIcon(new ImageIcon(getClass().getResource("/static/icon/icon_add.gif")));
        btnAddKey.setPadding(8);
        btnAddKey.setToolTipText("新增按键");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 0;
        panel2.add(btnAddKey, gbc);
        btnRefresh = new ImageButton();
        btnRefresh.setIcon(new ImageIcon(getClass().getResource("/img/icon_refresh.png")));
        btnRefresh.setPadding(5);
        btnRefresh.setToolTipText("刷新");
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        panel1.add(btnRefresh, gbc);
        btnDelete = new ImageButton();
        btnDelete.setIcon(new ImageIcon(getClass().getResource("/img/icon_delete.gif")));
        btnDelete.setPadding(5);
        btnDelete.setToolTipText("删除配置");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 0;
        panel1.add(btnDelete, gbc);
        txtAppConfigInfo = new ViewText();
        txtAppConfigInfo.setText("摇杆原始范围:[±x]\n状态刷新频率:?fps");
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = 0;
        gbc.gridheight = 2;
        gbc.insets = new Insets(0, 5, 0, 0);
        panel1.add(txtAppConfigInfo, gbc);
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.ipady = 3;
        gbc.insets = new Insets(5, 0, 0, 0);
        root.add(panel3, gbc);
        btnSave = new JButton();
        btnSave.setText("保存");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.ipadx = 50;
        panel3.add(btnSave, gbc);
        btnCancel = new JButton();
        btnCancel.setText("取消");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.ipadx = 50;
        panel3.add(btnCancel, gbc);
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel4, gbc);
        spKey = new HScrollPanel();
        spKey.setHorizontalScrollSize(new Dimension(-1, 5));
        spKey.setVerticalScrollBarPolicy(20);
        spKey.setVerticalScrollSize(new Dimension(5, -1));
        spKey.setVerticalScrollUnit(30);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel4.add(spKey, gbc);
        spKey.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new GridBagLayout());
        spKey.setViewportView(panel5);
        txtInfo = new JTextArea();
        txtInfo.setBackground(new Color(-986896));
        txtInfo.setEditable(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 10, 0, 10);
        panel5.add(txtInfo, gbc);
        pKey = new JPanel();
        pKey.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 0, 5);
        panel5.add(pKey, gbc);
        final KeyBindingItem nestedForm1 = new KeyBindingItem();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        pKey.add(nestedForm1.$$$getRootComponent$$$(), gbc);
        final KeyBindingItem nestedForm2 = new KeyBindingItem();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        pKey.add(nestedForm2.$$$getRootComponent$$$(), gbc);
        final JPanel spacer2 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.VERTICAL;
        panel5.add(spacer2, gbc);
        final JPanel panel6 = new JPanel();
        panel6.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        panel4.add(panel6, gbc);
        panel6.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "设备状态", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        txtStateInfo = new JTextArea();
        txtStateInfo.setBackground(new Color(-986896));
        txtStateInfo.setEditable(false);
        txtStateInfo.setMinimumSize(new Dimension(138, 28));
        txtStateInfo.setPreferredSize(new Dimension(138, 28));
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel6.add(txtStateInfo, gbc);
        ButtonGroup buttonGroup;
        buttonGroup = new ButtonGroup();
        buttonGroup.add(cbDInput);
        buttonGroup.add(cbHid);
        buttonGroup.add(cbXInput);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return root;
    }

}
